# -*- encoding=utf8 -*-
"""
RedFlag-TC0000122  （拍照进入装饰页）配乐检查
拍照进入自动配乐场景
调节原声和配乐音量场景
更多配乐选择场景
剪辑配乐场景
重置配乐为初始场景
删除配乐场景
"""
__author__ = "ldm"

import sys
import os

# 获取当前脚本所在目录.py
current_dir = os.path.dirname(os.path.abspath(__file__))
# 获取上级目录.air
parent_dir = os.path.dirname(current_dir)
# 获取上级目录air
grandparent_dir = os.path.dirname(parent_dir)
# 获取和air目录平级的conf、testcase目录路径
conf_dir = os.path.join(grandparent_dir, 'conf')
testcase_dir = os.path.join(grandparent_dir, 'testcase')
# 将conf、testcase目录添加到sys.path
sys.path.append(conf_dir)
sys.path.append(testcase_dir)

from PageFunction import CameraVideoShooter
from elements import *

auto_setup(__file__)
shooter = CameraVideoShooter()

log("--------------------------------拍照进入自动配乐场景--------------------------------------")
"""
调用方法拍照进入装饰页
获取配乐文本
断言
"""

shooter.enter_pictures_decoration_page()
text = shooter.get_element_text(decoration_page_background_music)
shooter.assert_texts_not_equal(text, "添加配乐", "断言失败，自动配乐失败")

log("--------------------------------调节原声和配乐音量场景--------------------------------------")
"""
点击配乐按钮
调节原声音量
调节配乐音量
获取原声音量文本
获取配乐音量文本
断言
"""
shooter.click_element(decoration_page_background_music)
touch((0.70, 0.77))
touch((0.255,0.83))
original_sound_text = shooter.get_element_text(background_music_original_sound)
Soundtrack_text = shooter.get_element_text(background_music_Soundtrack)
shooter.assert_texts_equal(original_sound_text, "0%", "断言失败，额能够改变原声音量说明没有置灰")
shooter.assert_texts_not_equal(Soundtrack_text, "100%", "断言失败，预期与实际数值一致说明没有成功调小音量")

log("--------------------------------更多配乐选择场景--------------------------------------")
"""
点击更多配乐按钮
选择配乐二
获取文本
断言
"""
shooter.click_element(background_music_more)
shooter.click_element(background_music_two)
touch((0.5,0.4))
add_music_text2 = shooter.get_element_text(poco("cn.migu.video.clip.walle:id/clip_rc_music_name_tv"))
shooter.assert_texts_equal(add_music_text2, "我在人民广场吃炸鸡-你猜我是谁", "断言失败，预期文案与实际文案不符合")

log("--------------------------------剪辑配乐场景--------------------------------------")
"""
点击配乐按钮
点击剪辑按钮
点击取消
点击剪辑按钮
滑动剪辑按钮
获取文本
断言
点击确认
点击剪辑
断言
"""
shooter.click_element(decoration_page_background_music)
shooter.click_element(background_music_clip)
shooter.click_element(background_music_clip_cancel)
shooter.click_element(background_music_clip)
shooter.swipe_screen((0.042,0.785), (0.45,0.785))
clip_text = shooter.get_element_text(background_music_clipsoundtrack_time)
shooter.assert_texts_not_equal(clip_text, "00:00", "断言失败，预期文案与实际文案一样，说明没有剪辑成功")
shooter.click_element(background_music_clip_confirm)
shooter.click_element(background_music_clip)
shooter.assert_texts_not_equal(clip_text, "00:00", "断言失败，预期文案与实际文案一样，说明没有剪辑成功")
shooter.click_element(background_music_clip_cancel)

log("--------------------------------重置配乐为初始场景--------------------------------------")
"""
点击重置按钮
点击取消
点击重置按钮
点击确认
断言
"""
shooter.click_element(background_music_reset)
shooter.click_element(background_music_reset_cancel)
shooter.click_element(background_music_reset)
shooter.click_element(background_music_reset_confirm)
music_text = shooter.get_element_text(poco("cn.migu.video.clip.walle:id/clip_rc_music_name_tv"))
shooter.assert_texts_equal(music_text, "我在人民广场吃炸鸡-你猜我是谁", "断言失败，预期文案与实际文案不一致")


log("--------------------------------删除配乐场景--------------------------------------")
"""
点击配乐按钮
点击配乐一
点击配乐按钮
点击删除按钮
点击取消
点击删除按钮
点击确认
断言
"""
shooter.click_element(decoration_page_background_music)
shooter.click_element(background_music_more)
shooter.click_element(background_music_one)
shooter.click_element(decoration_page_background_music)
shooter.click_element(background_music_delete)
shooter.click_element(background_music_delete_cancel)
shooter.click_element(background_music_delete)
shooter.click_element(background_music_delete_confirm)
no_soundtrack_text = shooter.get_element_text(background_music_name_text)
shooter.assert_texts_equal(no_soundtrack_text, "当前无配乐，快去挑选一个吧~", "断言失败，当前文案与预期文案不一致")

# 关闭应用
stop_app(UGC_package_name)